chore: enable CA1515 to prevent unnecessary public types#1698
Open
JamieMagee wants to merge 7 commits intomainfrom
Open
chore: enable CA1515 to prevent unnecessary public types#1698JamieMagee wants to merge 7 commits intomainfrom
JamieMagee wants to merge 7 commits intomainfrom
Conversation
Consolidate all [assembly: InternalsVisibleTo] attributes from scattered .cs files into their respective .csproj files using MSBuild items. Add cross-project InternalsVisibleTo entries to enable future phases of making implementation details internal: - Detectors → Orchestrator, Tests, TestsUtilities - Common → Tests, Orchestrator, Detectors, TestsUtilities - Orchestrator → Tests, CLI entry point, TestsUtilities - Contracts → Tests, TestsUtilities Remove scattered attributes from: - ComponentRecorder.cs - DependencyGraph.cs - TelemetryConstants.cs - IPyPiClient.cs Part of #455
Change public to internal for deserialization model classes that are implementation details across multiple detector ecosystems: conan, pnpm, swiftpm, vcpkg, rust (CargoLock, CargoToml, CargoSbom), poetry, yarn (Berry contracts, TypeConverter), npm (converters), pip (PipReportGraphNode, PythonVersion), and uv model classes. Types exposed through public interfaces/APIs are left public to maintain build compatibility. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Make ~80 classes internal in the Detectors project: - Data model/contract classes (ConanLock, PnpmYaml variants, PoetryLock, SwiftResolvedFile, VcpkgSBOM, CargoToml/Sbom, YarnBerry types, npm converters, PipReportGraphNode, PythonVersion, UvLock/Package, etc.) - Parser implementations (GoModParser, YarnLockParser, RustCargoLockParser, MavenStyleDependencyGraphParserService, PnpmParsingUtilities, etc.) - Concrete detector classes (NpmComponentDetector, NuGetComponentDetector, GoComponentDetector, RustSbomDetector, etc.) - Linux scanner internals (LinuxScanner, all component factories, filters) - Service implementations (MavenCommandService, PythonCommandService, PyPiClient, PipCommandService, YarnLockFileFactory, etc.) Kept public (used by downstream consumers): - All interfaces (IComponentDetector, IMavenCommandService, etc.) - MvnCliComponentDetector, MavenWithFallbackDetector (used in is-checks) - PipComponentDetector, SimplePipComponentDetector, PipReportComponentDetector (mocked in tests by component-detection-internal) Updated test classes to work with internal types via InternalsVisibleTo. Part of #455
Make ~50 classes internal in the Common project: - Telemetry records (~34 concrete classes): NuGetProjectAssetsTelemetryRecord, PyPiCacheTelemetryRecord, LinuxScannerTelemetryRecord, etc. Kept BaseDetectionTelemetryRecord public for external subclassing. - Utility classes: Column, TabularStringFormat, ComponentComparer, DependencyScopeComparer, DirectoryItemFacade(Optimized) - Docker reference exceptions (11 classes) - Concrete service implementations: CommandLineInvocationService, EnvironmentVariableService, PathUtilityService, FileUtilityService, DirectoryUtilityService, DockerService, ConsoleWritingService, SafeFileEnumerableFactory, ComponentStreamEnumerableFactory, FastDirectoryWalkerFactory Kept public: FileWritingService, ComponentStream, LazyComponentStream, ComponentRecorder, CommandLineInvocationResult, CommandLineTelemetryService, BaseDetectionTelemetryRecord, and all interfaces. Part of #455
Make 8 classes internal in the Orchestrator project: - Converter classes: CommaDelimitedConverter, KeyValueDelimitedConverter, SemicolonDelimitedConverter - CLI helpers: ArgumentHelper, IArgumentHelper - Concrete service implementations: DetectorProcessingService, DetectorRestrictionService, DefaultGraphTranslationService Kept public: ServiceCollectionExtensions, ScanExecutionService, ScanCommand, ScanSettings, LoggingEnricher, DetectorRestrictions, all experiment types, all service interfaces, DetectorRunResult, DetectorProcessingResult. Part of #455
Enable the CA1515 analyzer rule ("Make class internal") in
.editorconfig to prevent new unnecessary public types from
accumulating in the future.
This rule requires .NET 9+ SDK to enforce. Once the SDK is
upgraded, any new public class that could be internal will
produce a build warning.
Part of #455
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## jamiemagee/access-modifiers-orchestrator #1698 +/- ##
========================================================================
Coverage 90.8% 90.8%
========================================================================
Files 453 453
Lines 40344 40344
Branches 2447 2447
========================================================================
Hits 36653 36653
Misses 3191 3191
Partials 500 500 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ceb93da to
355692a
Compare
Base automatically changed from
jamiemagee/access-modifiers-orchestrator
to
main
March 6, 2026 22:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enable the CA1515 analyzer rule (
Make class internal) in.editorconfigto prevent new unnecessary public types from accumulating in the future.How it works
CA1515 flags
publicclasses that are not referenced by other assemblies and could safely beinternal. Combined withTreatWarningsAsErrors, this will make the build fail if someone adds a new unnecessarily public type.Note
This rule requires .NET 9+ SDK to enforce. On the current .NET 8 SDK it's a no-op. Once the SDK is upgraded, it will automatically start catching new public types that should be internal.
Stacked on #1696
Part of #455